package com.freshmarket.freshmarket.entity;


import com.freshmarket.freshmarket.utils.Result;
import lombok.Data;

import java.util.List;

@Data
public class Pages<T> extends Result {

    //当前页码
    private int pageIndex;
    //总条数
    private int pageCount;
    //每页显示条数
    private int pageSize;
    //起始页
    //private long pageStart;
    //总页数
    private int totalPage;
    //当前页的内容
    private List<T> content;

    public Pages(boolean success, int code, String message, int pageIndex, int pageCount, int pageSize, List<T> content) {
        super(success, code, message, null);
        this.pageIndex = pageIndex;
        this.pageCount = pageCount;
        this.pageSize = pageSize;
        this.totalPage = pageCount%pageSize==0?pageCount/pageSize:(pageCount/pageSize)+1;
        this.content = content;
    }

    public static Pages success(int pageCount, int pageIndex, int pageSize, List<?> content){
        return new Pages(true,200,"查询成功",pageIndex,pageCount,pageSize,content);
    }
}
